home *** CD-ROM | disk | FTP | other *** search
/ Pocket PC Game Programming / Pocket PC Game Programming.iso / source.exe / CH15 / GameLibrary / CWaveDevice.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-09  |  2.8 KB  |  131 lines

  1. ////////////////////////////////////////////////////////////
  2. // Pocket PC Game Programming
  3. // Chapter 10: Sound Effects and Music
  4. //
  5. // CWaveDevice Source File
  6. //
  7. // This file includes the CWaveDevice implementation.
  8. //
  9. ////////////////////////////////////////////////////////////
  10.  
  11. #include "stdafx.h"
  12. #include "CWaveDevice.h"
  13.  
  14. ////////////////////////////////////////////////////////////
  15. // CWaveDevice Constructor
  16. //
  17. // This function is called when the class is instantiated.
  18. //
  19. CWaveDevice::CWaveDevice()
  20. {
  21.     caps = new WAVEOUTCAPS;
  22. }
  23.  
  24. ////////////////////////////////////////////////////////////
  25. // CWaveDevice Destructor
  26. //
  27. // This function is called when the class is terminated.
  28. //
  29. CWaveDevice::~CWaveDevice()
  30. {
  31.     delete caps;
  32. }
  33.  
  34. ////////////////////////////////////////////////////////////
  35. // CWaveDevice::DeviceFound
  36. //
  37. // Determines if sound hardware is available.
  38. //
  39. BOOL CWaveDevice::DeviceFound()
  40. {
  41.     return (BOOL)(waveOutGetNumDevs() > 0);
  42.     
  43. }
  44.  
  45. ////////////////////////////////////////////////////////////
  46. // CWaveDevice::SupportsPlayback
  47. //
  48. // Determines whether minimum wave playback is supported.
  49. //
  50. BOOL CWaveDevice::SupportsPlayback()
  51. {
  52.     BOOL bRet;
  53.  
  54.     res = waveOutGetDevCaps(WAVE_MAPPER, caps, sizeof(WAVEOUTCAPS));
  55.     if (res != MMSYSERR_NOERROR)
  56.     {
  57.         return FALSE;
  58.     }
  59.     
  60.     if (caps->dwFormats & WAVE_FORMAT_1M08)
  61.         bRet = TRUE;
  62.     else
  63.         bRet = FALSE;
  64.  
  65.     return bRet;
  66. }
  67.  
  68. ////////////////////////////////////////////////////////////
  69. // CWaveDevice::SupportsStereo
  70. //
  71. // Determines whether stereo output is supported.
  72. //
  73. BOOL CWaveDevice::SupportsStereo()
  74. {
  75.     BOOL bRet;
  76.  
  77.     res = waveOutGetDevCaps(WAVE_MAPPER, caps, sizeof(WAVEOUTCAPS));
  78.     if (res != MMSYSERR_NOERROR)
  79.     {
  80.         return FALSE;
  81.     }
  82.     
  83.     if (caps->wChannels == 2)
  84.         bRet = TRUE;
  85.     else
  86.         bRet = FALSE;
  87.  
  88.     return bRet;
  89. }
  90.  
  91. ////////////////////////////////////////////////////////////
  92. // CWaveDevice::GetDriverVersion
  93. //
  94. // Returns the driver version of the sound driver.
  95. //
  96. float CWaveDevice::GetDriverVersion()
  97. {
  98.     byte major, minor;
  99.     float fRet;
  100.  
  101.     res = waveOutGetDevCaps(WAVE_MAPPER, caps, sizeof(WAVEOUTCAPS));
  102.     if (res != MMSYSERR_NOERROR)
  103.     {
  104.         return 0;
  105.     }
  106.  
  107.     major = caps->vDriverVersion & 0x0F;
  108.     minor = caps->vDriverVersion & 0xFF;
  109.     fRet = (float)(major + minor * 0.01);
  110.     return fRet;
  111. }
  112.  
  113. ////////////////////////////////////////////////////////////
  114. // CWaveDevice::GetDriverName
  115. //
  116. // Returns the sound driver name.
  117. //
  118. LPTSTR CWaveDevice::GetDriverName()
  119. {
  120.     MMRESULT res;
  121.  
  122.     res = waveOutGetDevCaps(WAVE_MAPPER, caps, sizeof(WAVEOUTCAPS));
  123.     if (res != MMSYSERR_NOERROR)
  124.     {
  125.         return NULL;
  126.     }
  127.     
  128.     return caps->szPname;
  129. }
  130.  
  131.